#include "header.hpp"
using namespace std;

//Singleton Pattern
//Create singleton on static area
//Core: constructor is private
//Feature: provide public interface to create object, set its return value as reference
void test11(){
    class Singleton{
    private:
        int x;
        int y;
        Singleton(int x, int y) : x(x), y(y){}

    public:
        //Provide public interface to create object
        static Singleton& getInstance(){
            static Singleton s(0, 0);
            return s;
        }

        void set(int x, int y){
            this->x = x;
            this->y = y;
        }

        void print(){
            cout << "(" << x << ", " << y << ")" << endl;
        }
    };


    Singleton& s = Singleton::getInstance();
    s.print();
    s.set(2, 3);
    s.print();
}
